package com.lintf.bot.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 
 * @TableName bot_message_retry
 */
@TableName(value ="bot_message_retry")
@Data
public class BotMessageRetry implements Serializable {
    /**
     * 主键id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 原始消息体
     */
    private String bodyMsg;

    /**
     * 交换器名称
     */
    private String exchangeName;

    /**
     * 路由键
     */
    private String routingKey;

    /**
     * 队列名称
     */
    private String queueName;

    /**
     * 最大重试次数
     */
    private Integer maxTryCount;

    /**
     * 当前重试次数
     */
    private Integer currentRetryCount;

    /**
     * 任务失败信息
     */
    private String errorMsg;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 消息类型 0.延时消息 1.重试消息
     */
    private Integer type;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        BotMessageRetry other = (BotMessageRetry) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getBodyMsg() == null ? other.getBodyMsg() == null : this.getBodyMsg().equals(other.getBodyMsg()))
            && (this.getExchangeName() == null ? other.getExchangeName() == null : this.getExchangeName().equals(other.getExchangeName()))
            && (this.getRoutingKey() == null ? other.getRoutingKey() == null : this.getRoutingKey().equals(other.getRoutingKey()))
            && (this.getQueueName() == null ? other.getQueueName() == null : this.getQueueName().equals(other.getQueueName()))
            && (this.getMaxTryCount() == null ? other.getMaxTryCount() == null : this.getMaxTryCount().equals(other.getMaxTryCount()))
            && (this.getCurrentRetryCount() == null ? other.getCurrentRetryCount() == null : this.getCurrentRetryCount().equals(other.getCurrentRetryCount()))
            && (this.getErrorMsg() == null ? other.getErrorMsg() == null : this.getErrorMsg().equals(other.getErrorMsg()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getBodyMsg() == null) ? 0 : getBodyMsg().hashCode());
        result = prime * result + ((getExchangeName() == null) ? 0 : getExchangeName().hashCode());
        result = prime * result + ((getRoutingKey() == null) ? 0 : getRoutingKey().hashCode());
        result = prime * result + ((getQueueName() == null) ? 0 : getQueueName().hashCode());
        result = prime * result + ((getMaxTryCount() == null) ? 0 : getMaxTryCount().hashCode());
        result = prime * result + ((getCurrentRetryCount() == null) ? 0 : getCurrentRetryCount().hashCode());
        result = prime * result + ((getErrorMsg() == null) ? 0 : getErrorMsg().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", bodyMsg=").append(bodyMsg);
        sb.append(", exchangeName=").append(exchangeName);
        sb.append(", routingKey=").append(routingKey);
        sb.append(", queueName=").append(queueName);
        sb.append(", maxTryCount=").append(maxTryCount);
        sb.append(", currentRetryCount=").append(currentRetryCount);
        sb.append(", errorMsg=").append(errorMsg);
        sb.append(", createTime=").append(createTime);
        sb.append(", type=").append(type);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}